package com.suitsoft.ut.service.commons;

import java.util.Date;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.suitsoft.ut.commons.UserHolder;
import com.suitsoft.ut.dao.commons.TimeAuthorityDao;
import com.suitsoft.ut.entity.account.User;
import com.suitsoft.ut.entity.system.TimeAuthority;

/**
 * 时间控制 管理 服务层类
 *@author Suineg
 */
@Service
@Transactional
public class TimeControlManager {
	/** 日志输出对象 */
	protected final Logger logger = LoggerFactory.getLogger(getClass());
	@Autowired
	private TimeAuthorityDao authorityDao;
	
	public TimeAuthority get(Long id){
		return authorityDao.get(id);
	}
	
	public void save(TimeAuthority authority){
		authority.setOpdate(new Date());
		User user = new User();
		user.setId(UserHolder.getLoginUser().getId());
		authority.setOpuser(user);
		authorityDao.save(authority);
	}
	
	public void delete(Long id){
		authorityDao.delete(id);
	}

}

